{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <legend>客户资料</legend>
            <hr>
            {foreach name="field" item="r"}
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.title}</label>
                    <div class="layui-input-block">
                        {if isset($data)}
                            {:get_code($r,$data)}
                        {else}
                            {:get_code($r)}
                        {/if}
                    </div>
                </div>
            </div>
            {/foreach}
            <hr>
            <legend>客服信息</legend>
            <hr>
            {foreach name="kefu" key="v" item="r"}
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">{$r}</label>
                    <div class="layui-input-block">
                        <select name="kefu[user_id][]" lay-search lay-verify='required'>
                            <option value="">请选择</option>
                            {foreach name="user_list" key="uv" item="u"}
                            <?php 
                                if(isset($data)){
                                    $this_user_id = \app\crm\model\CrmUser::where(['customer_id'=>$data['id'],'type_id'=>$v,'status'=>'1'])->value('user_id');
                                }else{
                                    $this_user_id = '';
                                }
                            ?>
                            <option value="{$u.id}" {if isset($data) and $this_user_id == $u.id}selected{/if}>{$u.name}</option>
                            {/foreach}
                        </select>
                        <input name="kefu[type_id][]" value="{$v}" type="hidden">
                    </div>
                </div>
            </div>
            {/foreach}
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script src="/static/js/jquery.min.js"></script>
    {foreach name="field" item="r"}
        {:get_code_js($r)}
    {/foreach}
{/block}